import objectUtils from "@/utils/object/index.js";

import config from "@/config/index.js";
			
export default objectUtils.freeze({
    success: function (content) {
        if (config.mode === "debug") {
            console.log(
                `%c ${ content ? content.toString() : content }`,
                'color: #ffffff;background: #76CA79;font-size: 12px;border-radius: 3px;padding: 3px 5px 3px 0'
            );
        }
    },
    error: function (content) {
        if (config.mode === "debug") {
            console.log(
                `%c ${ content ? content.toString() : content }`,
                'color: #ffffff;background: #F64E32;font-size: 12px;border-radius: 3px;padding: 3px 5px 3px 0'
            );
        }
    },
    warning: function (content) {
        if (config.mode === "debug") {
            console.log(
                `%c ${ content ? content.toString() : content }`,
                'color: #ffffff;background: #f0ad4e;font-size: 12px;border-radius: 3px;padding: 3px 5px 3px 0'
            );
        }
    },
    info: function (content) {
        if (config.mode === "debug") {
            console.log(
                `%c ${ content ? content.toString() : content }`,
                'color: #ffffff;background: #a8abb2;font-size: 12px;border-radius: 3px;padding: 3px 5px 3px 0'
            );
        }
    },
	data: function (data) {
	    if (config.mode === "debug") {
	        console.log(data);
	    }
	},
	request: function (response) {
        if (config.mode === "debug") {
			if(response.statusCode === 200){
				if(response.data.code === 0){
					console.log(
					    `%c【API - ${ response.config.custom.title }】请求：200`, 
						'color: #ffffff;background: #76CA79;font-size: 12px;border-radius: 3px;padding: 3px 5px 3px 0'
					);
				}else{
					console.log(
					    `%c【API - ${ response.config.custom.title }】请求：${ response.data.msg }`,
					    'color: #ffffff;background: #F64E32;font-size: 12px;border-radius: 3px;padding: 3px 5px 3px 0'
					);
				}
			}else{
				console.log(
				    `%c【API - ${ response.config.custom.title }】请求：${ response.statusCode }`,
				    'color: #ffffff;background: #F64E32;font-size: 12px;border-radius: 3px;padding: 3px 5px 3px 0'
				);
			}
        }
    }
});
